package com.hzcc.wechatpayback.module.controller;

import com.hzcc.wechatpayback.common.ResultResponse;
import com.hzcc.wechatpayback.module.service.WxPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 微信支付controller层
 *
 * @Author hzcc
 * @Date 2022/4/22
 */
@CrossOrigin
@Slf4j
@RestController
@RequestMapping("/api/wx-pay")
@Api(tags = "网站微信支付Api")
public class WxPayController {

    @Resource
    private WxPayService wxPayService;

    @ApiOperation("调用统一下单Api，生成支付二维码")
    @PostMapping("/native/{productId}")
    public ResultResponse nativePay(@PathVariable Long productId) throws Exception {
        log.info("发起支付请求");
        Map<String, Object> map = wxPayService.nativePay(productId);
        return ResultResponse.defaultSuccessResultResponse().setData(map);
    }

}
